﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;

namespace YellowMap
{
    [DataContract()]
    public class GooglePlaceDetailResponse
    {

        public static GooglePlaceDetailResponse ParseFromJSON(String jsonData)
        {

            GooglePlaceDetailResponse output;
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GooglePlaceDetailResponse));
            using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(jsonData)))
            {
                output = serializer.ReadObject(stream) as GooglePlaceDetailResponse;
            }
            return output;
        }
        [DataMember(Name = "result")]
        public result Result { get; set; }

        [DataMember(Name="status")]
        public string Status { get; set; }

        [DataContract()]
        public class result
        {
            [DataMember(Name = "types")]
            public List<string> Types { get; set; }

            [DataMember(Name = "url")]
            public string Url { get; set; }

            [DataMember(Name = "utc_offset")]
            public int UtcOffset { get; set; }

            [DataMember(Name = "vicinity")]
            public string Vicinity { get; set; }

            [DataMember(Name = "website")]
            public string Website { get; set; }

            [DataMember(Name = "address_components")]
            public List<address_component> AddressComponents { get; set; }

            [DataContract()]
            public class address_component
            {
                [DataMember(Name = "long_name")]
                public string LongName { get; set; }
                [DataMember(Name = "short_name")]
                public string ShortName { get; set; }
                [DataMember(Name = "types")]
                public List<string> Types { get; set; }
            }

            [DataMember(Name = "formatted_address")]
            public string FormattedAddress { get; set; }

            [DataMember(Name = "formatted_phone_number")]
            public string FormattedPhoneNumber { get; set; }

            [DataContract()]
            public class geometry
            {
                [DataMember(Name = "location")]
                public location Location { get; set; }

                [DataContract()]
                public class location
                {
                    [DataMember(Name = "lat")]
                    public double Latitude { get; set; }
                    [DataMember(Name = "lng")]
                    public double Longtitude { get; set; }
                }
            }

            [DataMember(Name = "icon")]
            public string Icon { get; set; }

            [DataMember(Name = "id")]
            public string Id { get; set; }

            [DataMember(Name = "international_phone_number")]
            public string InternationalPhoneNumber { get; set; }

            [DataMember(Name = "name")]
            public string Name { get; set; }

            [DataMember(Name = "rating")]
            public double Rating { get; set; }

            [DataMember(Name = "reference")]
            public string Reference { get; set; }

            [DataMember(Name = "reviews")]
            public List<review> Reviews { get; set; }

            [DataContract()]
            public class review
            {
                [DataMember(Name = "aspects")]
                public List<aspect> Aspects { get; set; }

                [DataContract()]
                public class aspect
                {
                    [DataMember(Name = "rating")]
                    public double Rating { get; set; }

                    [DataMember(Name = "type")]
                    public string Type { get; set; }
                }

                [DataMember(Name = "author_name")]
                public string AuthorName { get; set; }

                [DataMember(Name = "author_url")]
                public string AuthorUrl { get; set; }

                [DataMember(Name = "text")]
                public string Text { get; set; }

                [DataMember(Name = "time")]
                public long Time { get; set; }
            }
        }
    }
}
